package com.fss.shop.service.impl;

import com.fss.home.domain.Product;
import com.fss.shop.domain.Shop;
import com.fss.shop.mapper.ShopMapper;
import com.fss.shop.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ShopServiceImpl implements ShopService
{
    @Autowired
    private ShopMapper shopMapper;
    public Shop findShopByUserId(Long userId) {
        return shopMapper.selectShopByUserId(userId);
    }
    public List<Product> getProductsByShopId(Long shopId, Integer sortIndex, Double priceMin, Double priceMax) {
        return shopMapper.selectProductsByShopUserId(shopId, sortIndex, priceMin, priceMax);
    };
    @Override
    public int createShop(Shop shop) {
        return shopMapper.insertShop(shop);
    }
    @Override
    public boolean updateShop(Shop shop) {
        int rows = shopMapper.updateShop(shop);
        return rows > 0;
    }
}
